package servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.session.SqlSession;

import bean.OrderDetail;
import bean.Orders;
import mapper.OrdersMapper;
import util.MybatisUtil;

@WebServlet("/FaHuoOrdersServlet")
public class FaHuoOrdersServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		SqlSession sqlSession = MybatisUtil.getSqlSession();
		OrdersMapper mapper = sqlSession.getMapper(OrdersMapper.class);
		ArrayList<Orders> list= mapper.getFaHuoAllOrders();
		for (Orders orders : list) {
			System.out.println();
			for (OrderDetail orders3 : orders.getOrderDetailList()) {
				System.out.println(orders3);
			}
		}
		
		request.setAttribute("allOrders", list);		
		request.getRequestDispatcher("/Member-fahuo.jsp").forward(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
